package xyz.hujf.base.threadLocal;

/**
 * @author Hujf
 * @title: TestThreadLocal
 * @date 2021-04-2310:07
 * @description: 一般情况下不能子宣称不能获得主线程的参数
 *
 * 用InheritableThreadLocal
 */
public class TestThreadLocal {

    static ThreadLocal<String> local = new ThreadLocal<String>();
    static InheritableThreadLocal <String> hlocal = new InheritableThreadLocal<>();
    public static void main(String[] args) {
        local.set(" ia main");
        hlocal.set(" ia kid" );
        Thread thread = new Thread(()->{
            System.out.println(local.get());
            System.out.println(hlocal.get());
        });

        System.out.println(hlocal.get());
        System.out.println(local.get());
        local.remove();
        System.out.println(local.get());

        thread.start();

    }
}
